$import('Model');
$import('ArrayUtil')
var ArrayModel = $createClass('ArrayModel',function(param){
	this.Model(param);
	this.array = param.array;
	//this.datas = param.array;
},'Model');

ArrayModel.prototype.doSearch = function(){
	//this.datas = this.array;
	return this.array;
}

ArrayModel.prototype.add = function(pojo){
	this.array.push(pojo);
	this.refresh();
}

ArrayModel.prototype.update = function(pojo){
	var index = this.getIndexByPojo(pojo);
	if(index>-1){
		this.array[index] = pojo;
	}
	this.refresh();
}
ArrayModel.prototype.del = function(pojo){
	var index = this.getIndexByPojo(pojo);
	if(index>-1){
		ArrayUtil.delByIndex(this.array,index);
	}
	this.refresh();
}



ArrayModel.prototype.getIndexByPojo = function(pojo){
	var ret = -1;
	var self = this;
	ArrayUtil.foreach(this.array,function(n,obj){
		if(self.getPkValue(obj)==self.getPkValue(pojo)){
			ret = n;
		}
	});
	return ret;
}